package com.zxx.admin.service.base.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zxx.admin.entity.base.CodeStudyDetailEntity;
import com.zxx.admin.entity.base.CodeStudyEntity;
import com.zxx.admin.mapper.base.CodeStudyDetailMapper;
import com.zxx.admin.service.base.CodeStudyDetailService;
import com.zxx.admin.service.base.CodeStudyService;
import com.zxx.admin.vo.code.CodeStudyVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
 * @Description:  服务实现
 * @author: zhuangxx
 * @date 2020-07-13
 */
@Service
public class CodeStudyDetailServiceImpl extends ServiceImpl<CodeStudyDetailMapper, CodeStudyDetailEntity> implements CodeStudyDetailService {

    /**
     *   code 服务
     */
    @Autowired
    private CodeStudyService codeStudyService;

    /**
     *   通过Id查询Code
     */
    @Override
    public CodeStudyVO getCodeById(String codeNo) {

        QueryWrapper<CodeStudyEntity> ew1 = new QueryWrapper<>();
        ew1.eq("code_no", codeNo);

        QueryWrapper<CodeStudyDetailEntity> ew2 = new QueryWrapper<>();
        ew2.eq("code_no", codeNo);

        CodeStudyVO codeStudyVO = new CodeStudyVO();
        CodeStudyEntity codeStudyEntity = codeStudyService.getOne(ew1);
        CodeStudyDetailEntity codeStudyDetailEntity = this.getOne(ew2);

        codeStudyVO.setCodeNo(codeNo);
        codeStudyVO.setCodeTitle(codeStudyEntity.getCodeTitle());
        codeStudyVO.setCodeDetail(codeStudyDetailEntity.getCodeDetail());
        codeStudyVO.setId(codeStudyEntity.getId());
        return codeStudyVO;
    }
}
